<?php
/**
 * User: 呆呆
 * Agreement: 禁止使用本软件（系统）用于任何违法违规业务或项目,造成的任何法律后果允由使用者（或运营者）承担
 * Date: 2021/3/3
 * Time: 14:34
 */
namespace app\index\controller;
use think\Db;
use think\Controller;
use think\facade\Cookie;

class User extends Controller
{
    
    public function getReturn($code = 1, $msg = "成功", $data = null)
    {
        return array("code" => $code, "msg" => $msg, "data" => $data);
    }
    
    //商户登录状态
    public function dernout()
    {
        if (!Cookie::has(md5(date("Y-m")),md5(date("Y-m-d")))){
            $this->redirect("user/login");
        }
        $dsa = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        $data = Db::name("pay_sz")->find();
        if($data['ds_hfw']==2 and $dsa['type']<2){
            $this->success('网站正在升级维护中....',null,$data['ds_outr']);
        }else if(!$dsa || $dsa['active'] == 1 || $dsa['ip'] != real_ip() and $dsa['type']<2){
            Db::name("pay_user")->where("user",Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->update(array("scsj"=>time()));
            Cookie::delete(md5(date("Y-m")),md5(date("Y-m-d")));
            Cookie::clear(md5(date("Y-m-d")));
            Cookie::delete(md5(date("m-Y")),md5(date("d-m-Y")));
            Cookie::clear(md5(date("d-m-Y")));
            $this->redirect("user/login");
        }else{
            yecz();//检测余额充值
        }
    }
    
    //系统管理菜单
    public function getMenu()
    {
        $menu = array(
            array(//默认加载主页
                "url" => "../user/workplace",//主页路径
                "i" => "layui-icon-home",//图标

                
            ),array(//商户管理
                "name" => "arrow1",
                "type" => "nav",
                "url" => "xt1",
                "node" => array(//下级菜单
                    array(//单按钮
                        "name" => "商户中心",//标题
                        "i" => "layui-icon-home",//图标
                        "type" => "url",//单窗类型
                        "url" => "../user/workplace",//页面路径
                    ),array(//多按钮
                        "name" => "账号管理",//标题
                        "i" => "layui-icon-user",//图标
                        "type" => "menu",//多窗类型
                        "node" => array(//下级菜单
                            array(
                                "name" => "我的账号",//标题
                                "url" => "../user/user",//链接
                            ),array(
                                "name" => "异常账号",//标题
                                "url" => "../user/bug_list",//链接
                            ),
                        )
                    ),array(//多按钮
                        "name" => "通道管理",//标题
                        "i" => "layui-icon-app",//图标
                        "type" => "menu",//多窗类型
                        "node" => array(//下级菜单
                            array(
                                "name" => "常用通道",//标题
                                "url" => "../user/changyon",//链接
                            ),array(
                                "name" => "全部通道",//标题
                                "url" => "../user/quanbtodao",//链接
                            ),
                        )
                    ),array(//单按钮
                        "name" => "订单管理",//标题
                        "i" => "layui-icon-cart",//图标
                        "type" => "url",//单窗类型
                        "url" => "../user/list",//链接
                    ),array(//单按钮
                        "name" => "会员套餐",//标题
                        "i" => "layui-icon-diamond",//图标
                        "type" => "url",//单窗类型
                        "url" => "../user/tablecard",//链接
                    ),array(//单按钮
                        "name" => "余额充值",//标题
                        "i" => "layui-icon-rmb",//图标
                        "type" => "url",//单窗类型
                        "url" => "../user/chozhi",//链接
                    ),array(//单按钮
                        "name" => "接口信息",//标题
                        "i" => "layui-icon-about",//图标
                        "type" => "url",//单窗类型
                        "url" => "../user/jieko",//链接
                    ),array(//单按钮
                        "name" => "支付监控",//标题
                        "i" => "layui-icon-console",//图标
                        "type" => "url",//单窗类型
                        "url" => "../user/jiankong",//链接
                    ),

                )
                
                
            ),array(//后台管理
                "name" => "layui-hide",
                "type" => "nav",
                "url" => "xt2",
                "node" => array(//下级菜单
                    array(//单按钮
                        "name" => "后台中心",//标题
                        "i" => "layui-icon-home",//图标
                        "type" => "url",//首页类型
                        "url" => "../admin/workplace",//链接
                    ),array(//多按钮
                        "name" => "基本管理",//标题
                        "i" => "layui-icon-set",//图标
                        "type" => "menu",//多窗类型
                        "node" => array(//下级菜单
                            array(
                                "name" => "基本配置",//标题
                                "url" => "../admin/config",//链接
                            ),array(
                                "name" => "其他配置",//标题
                                "url" => "../admin/config_set",//链接
                            ),array(
                                "name" => "公告配置",//标题
                                "url" => "../admin/news",//链接
                            ),array(
                                "name" => "通知配置",//标题
                                "url" => "../admin/msg",//链接
                            ),
                        )
                    ),array(//多按钮
                        "name" => "通道管理",//标题
                        "i" => "layui-icon-app",//图标
                        "type" => "menu",//多窗类型
                        "node" => array(//下级菜单
                            array(
                                "name" => "通道配置",//标题
                                "url" => "../admin/game",//链接
                            ),array(
                                "name" => "账号配置",//标题
                                "url" => "../admin/land",//链接
                            ),
                        )
                    ),array(//单按钮
                        "name" => "会员管理",//标题
                        "i" => "layui-icon-diamond",//图标
                        "type" => "url",//单窗类型
                        "url" => "../admin/tablecard",//链接
                    ),array(//单按钮
                        "name" => "商户管理",//标题
                        "i" => "layui-icon-user",//图标
                        "type" => "url",//单窗类型
                        "url" => "../admin/user",//链接
                    ),array(//单按钮
                        "name" => "订单管理",//标题
                        "i" => "layui-icon-cart",//图标
                        "type" => "url",//单窗类型
                        "url" => "../admin/orders",//链接
                    ),

                )
            )

            
        );
        
        return json($menu);
        
    }
    
    //模板链接指令：系统管理
    public function index()
    {
        $this->dernout();//判断登录状态
        
        $dat = Db::name("pay_sz")->find();
        $data = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        $data['name'] = $dat['web_name'];//标题
        $data['web_name'] = $dat['web_name'];
        $data['keywords'] = $dat['web_keywords'];
        $data['description'] = $dat['web_description'];
        $data['web_beian'] = $dat['web_beian'];
        $data['wuqhhdd'] = ($dat['tz_denglu']==''?'0':'1');
        $data['tz_denglu'] = $dat['tz_denglu'];
        // 模板变量赋值
        $this->assign('data',$data);
        // 或者批量赋值
        return $this->fetch();
    }
    //系统管理-商户登录退出
    public function logout()
    {
        Db::name("pay_user")->where("user",Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->update(array("scsj"=>time()));
        Cookie::delete(md5(date("Y-m")),md5(date("Y-m-d")));
        Cookie::clear(md5(date("Y-m-d")));
        Cookie::delete(md5(date("m-Y")),md5(date("d-m-Y")));
        Cookie::clear(md5(date("d-m-Y")));
        $this->redirect("user/login");
    }
    //系统管理-商户修改密码
    public function info_save()
    {
        $this->dernout();//判断登录状态
        
        $oldPsw = input("oldPsw");
        if (!$oldPsw || $oldPsw == "") {
            return json($this->getReturn(-1, "请输入原始密码"));
        }
        $newPsw = input("newPsw");
        if (!$newPsw || $newPsw == "") {
            return json($this->getReturn(-1, "请输入新密码"));
        }
        $rePsw = input("rePsw");
        if (!$rePsw || $rePsw == "") {
            return json($this->getReturn(-1, "请再次输入新密码"));
        }
        if (!$newPsw===$rePsw) {
            return json($this->getReturn(-1, "两次输入不一致"));
        }
        $data = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        if (!password_verify($oldPsw, $data["pass"])) {
            return json($this->getReturn(-1, "原始密码错误"));
        }else{
            Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->update(array("pass"=>password_hash($newPsw, PASSWORD_DEFAULT)));
            Cookie::delete(md5(date("Y-m")),md5(date("Y-m-d")));
            Cookie::clear(md5(date("Y-m-d")));
            return json($this->getReturn(1, "修改密码成功"));
        }
    }
    
    //模板链接指令：商户中心
    public function workplace(){
        
        $this->dernout();//判断登录状态
        
        $data = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        $data['name'] = '商户中心';//标题
        if($data['type'] == '1'){
        $taocan = Db::name("pay_taocan")->where("id", $data['taocan'])->find();
        $data['fee'] = $taocan['taocan_quanx1'];//商户费率
        $data['type'] = '会员身份';//商户类型
        }else if($data['type'] == '2'){
            $data['fee'] = '0';//商户费率
            $data['type'] = '管理员';//商户类型
        }else{
            $data['type'] = '普通身份';//商户类型
        }
        ;//商户类型
        $data['todayOrder_jintian'] = Db::table('pay_order') ->where("pid", $data["id"])->whereTime('create_date', 'today')->count();//今日订单
        $data['todayOrder_zuotian'] =  Db::table('pay_order') ->where("pid", $data["id"])->whereTime('create_date', 'yesterday')->count();//昨日订单
        $data['todayMoney_jintian'] = Db::table('pay_order') ->where("pid", $data["id"])->where("state",2)->whereTime('create_date', 'today')->sum("price");//今日收入
        $data['todayMoney_zuotian'] = Db::table('pay_order') ->where("pid", $data["id"])->where("state",2)->whereTime('create_date', 'yesterday')->sum("price");//昨日收入
        
        $jeyue_1 = Db::name('pay_order')->where("pid", $data["id"])->where("state",2)->where("create_date >=".strtotime(date("Y-".'01'),time()))->where("create_date <=".(strtotime(date("Y-".'01'),time())+2626560))->sum("price");//1月成交订单金额
        $jeyue_2 = Db::name('pay_order')->where("pid", $data["id"])->where("state",2)->where("create_date >=".strtotime(date("Y-".'02'),time()))->where("create_date <=".(strtotime(date("Y-".'02'),time())+2626560))->sum("price");//2月成交订单金额
        $jeyue_3 = Db::name('pay_order')->where("pid", $data["id"])->where("state",2)->where("create_date >=".strtotime(date("Y-".'03'),time()))->where("create_date <=".(strtotime(date("Y-".'03'),time())+2626560))->sum("price");//3月成交订单金额
        $jeyue_4 = Db::name('pay_order')->where("pid", $data["id"])->where("state",2)->where("create_date >=".strtotime(date("Y-".'04'),time()))->where("create_date <=".(strtotime(date("Y-".'04'),time())+2626560))->sum("price");//4月成交订单金额
        $jeyue_5 = Db::name('pay_order')->where("pid", $data["id"])->where("state",2)->where("create_date >=".strtotime(date("Y-".'05'),time()))->where("create_date <=".(strtotime(date("Y-".'05'),time())+2626560))->sum("price");//5月成交订单金额
        $jeyue_6 = Db::name('pay_order')->where("pid", $data["id"])->where("state",2)->where("create_date >=".strtotime(date("Y-".'06'),time()))->where("create_date <=".(strtotime(date("Y-".'06'),time())+2626560))->sum("price");//6月成交订单金额
        $jeyue_7 = Db::name('pay_order')->where("pid", $data["id"])->where("state",2)->where("create_date >=".strtotime(date("Y-".'07'),time()))->where("create_date <=".(strtotime(date("Y-".'07'),time())+2626560))->sum("price");//7月成交订单金额
        $jeyue_8 = Db::name('pay_order')->where("pid", $data["id"])->where("state",2)->where("create_date >=".strtotime(date("Y-".'08'),time()))->where("create_date <=".(strtotime(date("Y-".'08'),time())+2626560))->sum("price");//8月成交订单金额
        $jeyue_9 = Db::name('pay_order')->where("pid", $data["id"])->where("state",2)->where("create_date >=".strtotime(date("Y-".'09'),time()))->where("create_date <=".(strtotime(date("Y-".'09'),time())+2626560))->sum("price");//9月成交订单金额
        $jeyue_10 = Db::name('pay_order')->where("pid", $data["id"])->where("state",2)->where("create_date >=".strtotime(date("Y-".'10'),time()))->where("create_date <=".(strtotime(date("Y-".'10'),time())+2626560))->sum("price");//10月成交订单金额
        $jeyue_11 = Db::name('pay_order')->where("pid", $data["id"])->where("state",2)->where("create_date >=".strtotime(date("Y-".'11'),time()))->where("create_date <=".(strtotime(date("Y-".'11'),time())+2626560))->sum("price");//11月成交订单金额
        $jeyue_12 = Db::name('pay_order')->where("pid", $data["id"])->where("state",2)->where("create_date >=".strtotime(date("Y-".'12'),time()))->where("create_date <=".(strtotime(date("Y-".'12'),time())+2626560))->sum("price");//12月成交订单金额
        
        $ddyue_1 = Db::name('pay_order')->where("pid", $data["id"])->where("state",2)->where("create_date >=".strtotime(date("Y-".'01'),time()))->where("create_date <=".(strtotime(date("Y-".'01'),time())+2626560))->count();//1月成交订单数
        $ddyue_2 = Db::name('pay_order')->where("pid", $data["id"])->where("state",2)->where("create_date >=".strtotime(date("Y-".'02'),time()))->where("create_date <=".(strtotime(date("Y-".'02'),time())+2626560))->count();//2月成交订单数
        $ddyue_3 = Db::name('pay_order')->where("pid", $data["id"])->where("state",2)->where("create_date >=".strtotime(date("Y-".'03'),time()))->where("create_date <=".(strtotime(date("Y-".'03'),time())+2626560))->count();//3月成交订单数
        $ddyue_4 = Db::name('pay_order')->where("pid", $data["id"])->where("state",2)->where("create_date >=".strtotime(date("Y-".'04'),time()))->where("create_date <=".(strtotime(date("Y-".'04'),time())+2626560))->count();//4月成交订单数
        $ddyue_5 = Db::name('pay_order')->where("pid", $data["id"])->where("state",2)->where("create_date >=".strtotime(date("Y-".'05'),time()))->where("create_date <=".(strtotime(date("Y-".'05'),time())+2626560))->count();//5月成交订单数
        $ddyue_6 = Db::name('pay_order')->where("pid", $data["id"])->where("state",2)->where("create_date >=".strtotime(date("Y-".'06'),time()))->where("create_date <=".(strtotime(date("Y-".'06'),time())+2626560))->count();//6月成交订单数
        $ddyue_7 = Db::name('pay_order')->where("pid", $data["id"])->where("state",2)->where("create_date >=".strtotime(date("Y-".'07'),time()))->where("create_date <=".(strtotime(date("Y-".'07'),time())+2626560))->count();//7月成交订单数
        $ddyue_8 = Db::name('pay_order')->where("pid", $data["id"])->where("state",2)->where("create_date >=".strtotime(date("Y-".'08'),time()))->where("create_date <=".(strtotime(date("Y-".'08'),time())+2626560))->count();//8月成交订单数
        $ddyue_9 = Db::name('pay_order')->where("pid", $data["id"])->where("state",2)->where("create_date >=".strtotime(date("Y-".'09'),time()))->where("create_date <=".(strtotime(date("Y-".'09'),time())+2626560))->count();//9月成交订单数
        $ddyue_10 = Db::name('pay_order')->where("pid", $data["id"])->where("state",2)->where("create_date >=".strtotime(date("Y-".'10'),time()))->where("create_date <=".(strtotime(date("Y-".'10'),time())+2626560))->count();//10月成交订单数
        $ddyue_11 = Db::name('pay_order')->where("pid", $data["id"])->where("state",2)->where("create_date >=".strtotime(date("Y-".'11'),time()))->where("create_date <=".(strtotime(date("Y-".'11'),time())+2626560))->count();//11月成交订单数
        $ddyue_12 = Db::name('pay_order')->where("pid", $data["id"])->where("state",2)->where("create_date >=".strtotime(date("Y-".'12'),time()))->where("create_date <=".(strtotime(date("Y-".'12'),time())+2626560))->count();//12月成交订单数
        
        $data['fhsjaj1'] = 'eval(['.$jeyue_1.','.$jeyue_2.','.$jeyue_3.','.$jeyue_4.','.$jeyue_5.','.$jeyue_6.','.$jeyue_7.','.$jeyue_8.','.$jeyue_9.','.$jeyue_10.','.$jeyue_11.','.$jeyue_12.'])';//成交订单金额（元）
        $data['fhsjaj2'] = 'eval(['.$ddyue_1.','.$ddyue_2.','.$ddyue_3.','.$ddyue_4.','.$ddyue_5.','.$ddyue_6.','.$ddyue_7.','.$ddyue_8.','.$ddyue_9.','.$ddyue_10.','.$ddyue_11.','.$ddyue_12.'])';//成交订单数（笔）
        
        $news_data =  Db::name('pay_gogao')->order('state desc')->order('id desc')->limit(8)->select();
        
        // 模板变量赋值
        $this->assign('data',$data);
        $this->assign('news_data',$news_data);
        return $this->fetch();
    }
    //模板链接指令：商户中心-公告页面
    public function news($id){
        
        $data = Db::name("pay_gogao")->where("id", $id)->find();
        if(!$data){
            
            $this->success('1001',null,'公告不存在');
            
        }
        // 模板变量赋值
        $this->assign('news',$data);
        return $this->fetch();
        
    }
    
    //模板链接指令：会员套餐
    public function tablecard(){
        
        $this->dernout();//判断登录状态
        
        $data = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        $dawd = Db::name("pay_taocan")->where("id", $data['taocan'])->find();
        if($data['type']=='2'){
        $data['taocan_name'] = '管理员权限';//套餐名称
        $data['create_time'] = '永久';//过期时间戳
        $data['taocan_quanx1'] = '0';//套餐费率权限
        $data['taocan_quanx2'] = '1';//套餐免签付(微信)免监控权限
        }else if($dawd and $data['type']=='1'){
        $data['taocan_name'] = $dawd['taocan_name'];//套餐名称
        $data['create_time'] = ($data['taocan_time'] !='0'?timer(date("Y-m-d H:i:s",$data['taocan_time'])):'永久');//过期时间戳
        $data['taocan_quanx1'] = $dawd['taocan_quanx1'];//套餐费率权限
        $data['taocan_quanx2'] = $dawd['taocan_quanx2'];//套餐免签付(微信)免监控权限
        }else{
        $data['taocan_name'] = '未开通';//套餐名称
        $data['create_time'] = '未开通';//过期时间戳
        $data['taocan_quanx1'] = '-1';//套餐费率权限
        $data['taocan_quanx2'] = '0';//套餐免签付(微信)免监控权限
            
        }
        
        $data['name'] = '会员套餐';//标题
        // 模板变量赋值
        $this->assign('data',$data);
        
        return $this->fetch();
    }
    //会员套餐-会员套餐表格数据
    public function tablecard_list(){
        
        $this->dernout();//判断登录状态
        
        $obj = Db::table('pay_taocan')->where("state", 1)->page(input("page"),input("limit"));
        
        $array = $obj->order("id","desc")->select();
        
        return json(array(
            "code"=>0,
            "msg"=>"获取成功",
            "result"=>
                    array(
                      "data"=>$array,
                      "total"=> $obj->count()
                    ),
        ));
    }
    //会员套餐-购买套餐
    public function tablecard_save()
    {
        $this->dernout();//判断登录状态
        
        $name = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        if (!$name) {
            return json($this->getReturn(-1, "请输入充值商户"));
        }
        $taocan = Db::name("pay_taocan")->where("id", input("id"))->find();
        if (!$taocan) {
            return json($this->getReturn(-1, "请输入正确购买套餐ID"));
        }
        $type = input("type");
        if (!$type || $type == "") {
            return json($this->getReturn(-1, "请选择充值方式"));
        }
        if ($name['type'] == 2) {
            return json($this->getReturn(-1, "管理员身份，无需开通或者续费"));
        }
        if ($name['money'] < $taocan['taocan_jiage']) {
            return json($this->getReturn(-1, "余额不足，请到余额充值页面充值"));
        }
        if($name['taocan']==$taocan['id']){
            if($name['taocan_time']==0){
                return json($this->getReturn(-1, '无需续费'));
            }
            $money = $name['money']-$taocan['taocan_jiage'];
            $taocan_time = $name['taocan_time']+$taocan['taocan_time']*86400;
            Db::name("pay_user")->where("id", $name['id'])->update(array("money"=>$money,"type"=>1,"taocan_time"=>$taocan_time));
            return json($this->getReturn(1, '续费成功'));
        }else{
            $money = $name['money']-$taocan['taocan_jiage'];
            $taocan_time = ($taocan['taocan_time'] !='0'?(time()+$taocan['taocan_time']*86400):'0');
            Db::name("pay_user")->where("id", $name['id'])->update(array("taocan"=>$taocan['id'],"money"=>$money,"type"=>1,"taocan_time"=>$taocan_time));
            return json($this->getReturn(1, '开通成功'));
        }
        
    }
    
    //模板链接指令：账号管理-我的账号
    public function user(){
        
        $this->dernout();//判断登录状态
        
        $re = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        $rows = Db::name("pay_gfg")->where("pid", $re['id'])->where("state",1)->select();
        foreach ($rows as $row){
            $z_pay =  Db::table('pay_order')->where("pid", $row['pid'])->where("mid", $row["mid"])->where("mid_id", $row["typec_id"])->where("state", 2)->sum("price");//总充值
            $jr_pay =  Db::table('pay_order')->where("pid", $row['pid'])->where("mid", $row["mid"])->where("mid_id", $row["typec_id"])->where("state", 2)->whereTime('create_date', 'today')->sum("price");//今日充值
            $zr_pay =  Db::table('pay_order') ->where("pid", $row['pid'])->where("mid", $row["mid"])->where("mid_id", $row["typec_id"])->where("state", 2)->whereTime('create_date', 'yesterday')->sum("price");//昨日充值
            Db::name("pay_gfg")->where("id", $row["id"])->where("pid", $row["pid"])->where("mid", $row["mid"])->update(array("z_pay"=>$z_pay,"jr_pay"=>$jr_pay,"zr_pay"=>$zr_pay));
        }
                
        $atad = Db::name("pay_sz")->find();
        $data['name'] = '账号管理-我的账号';//标题
        $data['gogao'] = $atad['tz_zhanghao'];//公告
        
        // 模板变量赋值
        $this->assign('data',$data);
        
        return $this->fetch();
    }
    //账号管理-我的账号-账号表格数据
    public function user_list(){
        
        $this->dernout();//判断登录状态
        
        $data = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        
        $obj = Db::table('pay_gfg')->where("pid", $data['id'])->where("state", 1)->page(input("page"),input("limit"));
        
        if (input("username")){
            $obj = $obj->where("state", 1)->where("username",input("username"));
        }
        if (input("typec_name")){
            $obj = $obj->where("state", 1)->where("typec_name",input("typec_name"));
        }
        
        $array = $obj->order("id","desc")->select();
        
        return json(array(
            "code"=>0,
            "msg"=>"获取成功",
            "result"=>
                    array(
                      "data"=>$array,
                      "total"=> $obj->count()
                    ),
        ));
    }
    //账号管理-我的账号-发起测试
    public function pay_demo(){
        
        $this->dernout();//判断登录状态
        
        if (!input("mid") || input("mid") == "") {
            $this->success('1001',null,'mid（附加信息：收款账号MID 参数错误');
        }
        if (!input("money") || input("money") == "") {
            $this->success('1001',null,'money（附加信息：测试金额 参数错误');
        }
        $atad = Db::name("pay_sz")->find();
        $data = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        $tada = Db::name("pay_gfg")->where("pid", $data['id'])->where("mid", input("mid"))->find();
        if(!$tada){
            $this->success('1002',null,'错误信息：收款账号MID不存在');
        }
        if($data['duijei']==1){//对接模式
        if($tada['type']=='1'){
            $type = 'alipay';
        }elseif($tada['type']=='0'){
            $type = 'weixin';
        }elseif($tada['type']=='2'){
            $type = 'qq';
        } 
		$api = array(
			"pid" => $tada['pid'],//商户ID
			"type" => $type,//支付方式
			"record"=> '测试发起',//附加参数
			"money"	=> input("money"),//付款金额
		    "mid"	=> input("mid"),//收款账号MID
			"refer" =>  http_type().url('user/refer'),//同步回调
			"notify" => http_type().url('pay/index/notify'),//异步通知
		);
		$url = laqzf($data,$api,$data['key']);//拉起支付
        }else{
        if($tada['type']=='1'){
            $type = 'alipay';
        }elseif($tada['type']=='0'){
            $type = 'wxpay';
        }elseif($tada['type']=='2'){
            $type = 'qqpay';
        }    
		$api = array(
			"pid" => $tada['pid'],//商户ID
			"type" => $type,//支付方式
			"out_trade_no"=> time(),//附加参数
			"money"	=> input("money"),//付款金额
			"name" => '测试发起',//商品名称
			"sitename" => '',//网站名称
			"return_url" =>  http_type().url('user/refer'),//同步回调
			"notify_url" => http_type().url('pay/index/notify'),//异步通知
		    "mid"	=> input("mid"),//收款账号MID
		);
		$url = laqzf($data,$api,$data['key']);//拉起支付
        }
        if($data){
            return json($this->getReturn(1, $url));
        }else{
            return json($this->getReturn(-1, "调用失败"));
        }
    }
    //账号管理-我的账号-修改限量配置
    public function ds_save(){
        
        $this->dernout();//判断登录状态
        
        if (!input("id") || input("id") == "") {
            $this->success('1001',null,'id（附加信息：账号ID 参数错误');
        }
        $data = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        $tada = Db::name("pay_gfg")->where("pid", $data['id'])->where("id", input("id"))->find();
        if(!$tada){
            $this->success('1002',null,'错误信息：账号ID不存在');
        }
        if(input("ds_time")==0 and input("ds_num")!=0){
            return json($this->getReturn(-1, "请设定时间（分钟）"));
        }
        if(input("ds_num")==0 and input("ds_time")!=0){
            return json($this->getReturn(-1, "请输入限量数量"));
        }
        $tada = Db::name("pay_gfg")->where("pid", $data['id'])->where("id", input("id"))->find();
        if($tada){
            Db::name("pay_gfg")->where("pid", $data['id'])->where("id", input("id"))->update(array("ds_time"=>input("ds_time"),"ds_type"=>input("ds_type"),"ds_num"=>input("ds_num"),"ds_status"=>0));
            return json($this->getReturn(1, "操作成功"));
        }else{
            return json($this->getReturn(-1, "操作失败"));
        }
    }
    //账号管理-我的账号-修改异常配置
    public function bug_set(){
        
        $this->dernout();//判断登录状态
        
        $data = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        
        if (input()) {
            
            if (input("bug_close") == "") {
                $this->success('1001',null,'bug_close（附加信息：订单过期时间 参数错误');
            }
            if (input("bug_num") == "") {
                $this->success('1002',null,'bug_num（附加信息：异常次数 参数错误');
            }
            if (!input("bug_type") || input("bug_type") == "") {
                $this->success('1003',null,'bug_type（附加信息：触发操作 参数错误');
            }
            if (input("bug_close") < 1 || input("bug_close") > 5) {
                return json($this->getReturn(-1, '请设置过期时间：1-5（分钟）'));
            }
            if(input("bug_num")==0){
                return json($this->getReturn(-1, "请设置账号异常次数"));
            }
            if($data['bug_close']==input("bug_close") and $data['bug_num']==input("bug_num") and $data['bug_type']==input("bug_type")){
                return json($this->getReturn(-1, '设置失败'));
            }else{
                Db::name("pay_user")->where("id", $data['id'])->update(array("bug_close"=>input("bug_close"),"bug_num"=>input("bug_num"),"bug_type"=>input("bug_type")));
                return json($this->getReturn(1, '设置成功'));
            }
        }
        return json(array(
            "bug_close"=>$data['bug_close'],//订单有效期
            "bug_num"=>$data['bug_num'],//异常次数
            "bug_type"=>$data['bug_type'],//触发操作
            ));
    }
    
    //模板链接指令：账号管理-异常账号
    public function bug_list(){
        
        $this->dernout();//判断登录状态
        
        $atad = Db::name("pay_sz")->find();
        $data['name'] = '账号管理-异常账号';//标题
        $data['gogao'] = $atad['tz_zhanghao'];//公告
        
        // 模板变量赋值
        $this->assign('data',$data);
        
        return $this->fetch();
    }
    //账号管理-异常账号-账号表格数据
    public function bug_land_list(){
        
        $this->dernout();//判断登录状态
        
        $data = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        
        $obj = Db::table('pay_gfg')->where("pid", $data['id'])->where("state", 0)->page(input("page"),input("limit"));
        
        if (input("username")){
            $obj = $obj->where("state", 0)->where("username",input("username"));
        }
        if (input("typec_name")){
            $obj = $obj->where("state", 0)->where("typec_name",input("typec_name"));
        }
        
        $array = $obj->order("id","desc")->select();
        
        return json(array(
            "code"=>0,
            "msg"=>"获取成功",
            "result"=>
                    array(
                      "data"=>$array,
                      "total"=> $obj->count()
                    ),
        ));
    }
    
    //账号管理-修改轮询状态
    public function status_save(){
        
        $this->dernout();//判断登录状态
        
        if (!input("id") || input("id") == "") {
            $this->success('1001',null,'id（附加信息：账号ID 参数错误');
        }
        $data = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        $tada = Db::name("pay_gfg")->where("pid", $data['id'])->where("id", input("id"))->find();
        if(!$tada){
            $this->success('1002',null,'错误信息：账号ID不存在');
        }
        if(input("land_lx")==1){
            Db::name("pay_gfg")->where("pid", $data['id'])->where("id", input("id"))->update(array("state"=>1,"bug_num"=>0,"bug_data"=>'')); 
        }
        $tada = Db::name("pay_gfg")->where("pid", $data['id'])->where("id", input("id"))->find();
        if($tada){
            Db::name("pay_gfg")->where("pid", $data['id'])->where("id", input("id"))->update(array("land_lx"=>input("land_lx")));
            return json($this->getReturn(1, "操作成功"));
        }else{
            return json($this->getReturn(-1, "操作失败"));
        }
    }
    //账号管理-删除账号
    public function del_save(){
        
        $this->dernout();//判断登录状态
        
        if (!input("id") || input("id") == "") {
            $this->success('1001',null,'id（附加信息：账号ID 参数错误');
        }
        $data = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        $tada = Db::name("pay_gfg")->where("pid", $data['id'])->where("id", input("id"))->find();
        if(!$tada){
            $this->success('1002',null,'错误信息：账号ID不存在');
        }
        $tada = Db::name("pay_gfg")->where("pid", $data['id'])->where("id", input("id"))->find();
        if($tada){
            Db::table('pay_gfg')->where("pid", $data['id'])->where("id", input("id"))->delete();
            return json($this->getReturn(1, "删除成功"));
        }else{
            return json($this->getReturn(-1, "删除失败"));
        }
    }
    //模板链接指令：账号管理-修改账号
    public function land_edit()
    {
        $this->dernout();//判断登录状态
        
        if (!input("id") || input("id") == "") {
            
            if (!input("username") || input("username") == "") {
                return json($this->getReturn(-1, "请输入账户备注"));
            }
            if (input("r_money") == "") {
                return json($this->getReturn(-1, "请输入日限额"));
            }
            if (input("z_money") == "") {
                return json($this->getReturn(-1, "请输入总限额"));
            }
            if (!input("game_id") || input("game_id") == "") {
                return json($this->getReturn(-1, "请输入通道ID"));
            }
            $data = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
            $tada = Db::name("pay_gfg")->where("pid", $data['id'])->where("id", input("game_id"))->find();
            $jkgj = Db::name("pay_jie")->where("pid", $data['id'])->where("id", $tada['typec_id'])->find();
                if($jkgj['game_dm']=='mq_gvxyjk'){
                    $fjhd = Db::name("pay_gfg")->where("pid", $data['id'])->where("zhanghao", input("zhanghao"))->find();
                    if($fjhd){
                        return json($this->getReturn(-1, "您修改的微信店员名称已存在，请重新修改！"));
                    }
                }
                error_reporting(0);
                $data = array(
                "username" => input("username"),//账号备注
                "zhanghao" => (input("zhanghao")==''?'无数据':input("zhanghao")),//通道账号
                "ck" => (input("ck")==''?'无数据':input("ck")),//通道CK数据
                "bf" => (input("bf")==''?'无数据':input("bf")),//通道备份数据
                "bfbf" => (input("bfbf")==''?'无数据':input("bfbf")),//通道备份数据
                "bfbfbf" => (input("bfbfbf")==''?'无数据':input("bfbfbf")),//通道备份数据
                "type" => input("type"),//支付方式
                "ms" => input("ms"),//支付模式
                "method" => input("method"),//回调方式
                "r_money" => input("r_money"),//日限额
                "z_money" => input("z_money"),//总限额
            
                );
            if($tada['username']==input("username") and $tada['zhanghao']==(input("zhanghao")==''?'无数据':input("zhanghao")) and $tada['ck']==(input("ck")==''?'无数据':input("ck")) and $tada['type']==input("type") and $tada['ms']==input("ms") and $tada['method']==input("method") and $tada['r_money']==input("r_money") and $tada['z_money']==input("z_money")){
                return json($this->getReturn(-1, '修改账号失败'));
            }else{
                Db::name("pay_gfg")->where("id", $tada['id'])->update($data);
                return json($this->getReturn(1, '修改账号成功'));
            }
        }else{
        $data = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        $tada = Db::name("pay_gfg")->where("pid", $data['id'])->where("id", input("id"))->find();
        $fdsf = Db::name("pay_jie")->where("pid", $data['id'])->where("id", $tada['typec_id'])->find();
        if(!$tada){
            $this->success('1002',null,'错误信息：账号ID不存在');
        }
        $tad = Db::name("pay_jie")->where("pid", $data['id'])->where("id", $tada['typec_id'])->find();
        $tada['game_name'] = $fdsf['game_name'];//通道名称
        // 模板变量赋值
        $this->assign('data',$tada);
        return $this->fetch('../application/common/view/'.$tad['game_dm'].'.html');
        }
    }
    
    //模板链接指令：通道管理-全部通道
    public function quanbtodao()
    {
        $this->dernout();//判断登录状态
        
        qbtdjckg(Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))));//全部通道-检测开关
        $re = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        $rows = Db::name("pay_jie")->where("pid", $re['id'])->where("state",1)->select();
        foreach ($rows as $row){
            $eer = Db::name("pay_gfg")->where("pid", $row["pid"])->where("typec_id",$row['id'])->find();
            $land_count = Db::name('pay_gfg')->where("pid", $row["pid"])->where("typec_id",$row['id'])->count();//账号数量
            $jr = Db::table('pay_order') ->where("pid", $row["pid"])->where("mid_id",$row['id'])->where("state",2)->whereTime('create_date', 'today')->sum("price");//今日收入
            $zr = Db::table('pay_order') ->where("pid", $row["pid"])->where("mid_id",$row['id'])->where("state",2)->whereTime('create_date', 'yesterday')->sum("price");//昨日收入
            Db::name("pay_jie")->where("pid", $row["pid"])->where("id", $row['id'])->update(array("land_count"=>$land_count,"jr_pay"=>$jr,"zr_pay"=>$zr));
        }
        $atad = Db::name("pay_sz")->find();
        $data['name'] = '全部通道';//标题
        $data['gogao'] = $atad['tz_todao'];//公告
        // 模板变量赋值
        $this->assign('data',$data);
        
        return $this->fetch();
    }
    //通道管理-全部通道-通道表格数据
    public function game_list(){
        
        $this->dernout();//判断登录状态
        
        $data = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        
        $obj = Db::table('pay_jie')->where("pid", $data['id'])->where("state", 1)->page(input("page"),input("limit"));
        
        if (input("game_name")){
            $obj = $obj->where("state", 1)->where("game_name",input("game_name"));
        }
        
        $array = $obj->order("id","desc")->select();
        
        return json(array(
            "code"=>0,
            "msg"=>"获取成功",
            "result"=>
                    array(
                      "data"=>$array,
                      "total"=> $obj->count()
                    ),
        ));
    }
    //模板链接指令：通道管理-常用通道
    public function changyon(){
        
        $this->dernout();//判断登录状态
        
        $re = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        $rows = Db::name("pay_jie")->where("pid", $re['id'])->where("state",1)->select();
        foreach ($rows as $row){
            $eer = Db::name("pay_gfg")->where("pid", $row["pid"])->where("typec_id",$row['id'])->find();
            $land_count = Db::name('pay_gfg')->where("pid", $row["pid"])->where("typec_id",$row['id'])->count();//账号数量
            $jr = Db::table('pay_order') ->where("pid", $row["pid"])->where("mid_id",$row['id'])->where("state",2)->whereTime('create_date', 'today')->sum("price");//今日收入
            $zr = Db::table('pay_order') ->where("pid", $row["pid"])->where("mid_id",$row['id'])->where("state",2)->whereTime('create_date', 'yesterday')->sum("price");//昨日收入
            Db::name("pay_jie")->where("pid", $row["pid"])->where("id", $row['id'])->update(array("land_count"=>$land_count,"jr_pay"=>$jr,"zr_pay"=>$zr));
        }
        $atad = Db::name("pay_sz")->find();
        $data['name'] = '常用通道';//标题
        $data['gogao'] = $atad['tz_todao'];//公告
        
        // 模板变量赋值
        $this->assign('data',$data);
        
        return $this->fetch();
    }
    //通道管理-常用通道-通道表格数据
    public function chang_list(){
        
        $this->dernout();//判断登录状态
        
        $data = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        
        $obj = Db::table('pay_jie')->where("pid", $data['id'])->where("game_my", 0)->where("state", 1)->page(input("page"),input("limit"));
        
        if (input("game_name")){
            $obj = $obj->where("game_my", 0)->where("state", 1)->where("game_name",input("game_name"));
        }
        
        $array = $obj->order("id","desc")->select();
        
        return json(array(
            "code"=>0,
            "msg"=>"获取成功",
            "result"=>
                    array(
                      "data"=>$array,
                      "total"=> $obj->count()
                    ),
        ));
    }
    //通道管理-通道常用设置
    public function cy_set(){
        
        $this->dernout();//判断登录状态
        
        if (!input("id") || input("id") == "") {
            $this->success('1001',null,'id（附加信息：订单ID 参数错误');
        }
        $data = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        $tada = Db::name("pay_jie")->where("pid", $data['id'])->where("id", input("id"))->find();
        if(!$tada||$tada['state']==0){
            $this->success('1002',null,'错误信息：订单ID不存在');
        }
        $tada = Db::name("pay_jie")->where("pid", $data['id'])->where("id", input("id"))->where("game_my",1)->find();
        if($tada){
            Db::name("pay_jie")->where("pid", $data['id'])->where("id", input("id"))->update(array("game_my"=>0));
            return json($this->getReturn(1, "设置常用成功"));
        }else{
            Db::name("pay_jie")->where("pid", $data['id'])->where("id", input("id"))->update(array("game_my"=>1));
            return json($this->getReturn(-1, "取消常用成功"));
        }
        
    }
    //模板链接指令：通道管理-添加账号
    public function land_add()
    {
        $this->dernout();//判断登录状态
        
        if (!input("id") || input("id") == "") {
            
            if (!input("username") || input("username") == "") {
                return json($this->getReturn(-1, "请输入账户备注"));
            }
            if (input("r_money") == "") {
                return json($this->getReturn(-1, "请输入日限额"));
            }
            if (input("z_money") == "") {
                return json($this->getReturn(-1, "请输入总限额"));
            }
            if (!input("game_id") || input("game_id") == "") {
                return json($this->getReturn(-1, "请输入通道ID"));
            }
            $data = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
            $tada = Db::name("pay_jie")->where("pid", $data['id'])->where("id", input("game_id"))->find();
            $mid =  Db::table('pay_gfg') ->count()+1;
            if($tada['game_dm']=='mq_gvxyjk'||$tada['game_dm']=='mq_gzfbyjk'||$tada['game_dm']=='mq_gqqyjk'){
                if($data['type']==1){
                    $taocan = Db::name("pay_taocan")->where("id", $data['taocan'])->find();
                    if($taocan){
                        if($data['taocan_time']>=time()||$data['taocan_time']==0){
                            if($taocan['taocan_quanx2']==0){
                                return json($this->getReturn(-1, "您的会员套餐里未开通云监控权限"));
                            }
                        }else{
                            Db::name("pay_user")->where("id", $data['id'])->update(array("type"=>0,"taocan"=>0,"taocan_time"=>0));
                            return json($this->getReturn(-1, "套餐云监控权限已过期"));
                        }
                    }else{
                        Db::name("pay_user")->where("id", $data['id'])->update(array("type"=>0,"taocan"=>0,"taocan_time"=>0));
                        return json($this->getReturn(-1, "未开通会员套餐云监控权限"));
                    }
                }else if($data['type']==2){
                }else{
                    return json($this->getReturn(-1, "您的会员套餐里未开通云监控权限"));
                }
                if($tada['game_dm']=='mq_gvxyjk'){
                    $fjhd = Db::name("pay_gfg")->where("pid", $data['id'])->where("zhanghao", input("zhanghao"))->find();
                    if($fjhd){
                        return json($this->getReturn(-1, "您输入的微信店员名称已存在，请重新输入！"));
                    }
                }
            }
                error_reporting(0);
                $data = array(
                    "pid" => $data['id'],//商户PID
                    "mid" => $mid.rand(100,6666),//收款账号MID
                    "typec_id" => input("game_id"),//通道ID
                    "username" => input("username"),//账号备注
                    "typec_id" => $tada['id'],//通道ID
                    "typec_name" => $tada['game_name'],//所属通道
                    "zhanghao" => (input("zhanghao")==''?'无数据':input("zhanghao")),//通道账号
                    "ck" => (input("ck")==''?'无数据':input("ck")),//通道CK数据
                    "bf" => (input("bf")==''?'无数据':input("bf")),//通道备份数据
                    "bfbf" => (input("bfbf")==''?'无数据':input("bfbf")),//通道备份数据
                    "bfbfbf" => (input("bfbfbf")==''?'无数据':input("bfbfbf")),//通道备份数据
                    "type" => input("type"),//支付方式
                    "ms" => input("ms"),//支付模式
                    "method" => input("method"),//回调方式
                    "r_money" => input("r_money"),//日限额
                    "z_money" => input("z_money"),//总限额
                    "create_date" => time(),//创建时间戳（10位）
                );
            Db::name("pay_gfg")->insert($data);
            return json($this->getReturn(1, '添加账号成功'));
        }else{
        $data = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        $tada = Db::name("pay_jie")->where("pid", $data['id'])->where("id", input("id"))->find();
        if(!$tada){
            $this->success('1002',null,'错误信息：账号ID不存在');
        }
        // 模板变量赋值
        $this->assign('data',$tada);
        return $this->fetch('../application/common/view/'.$tada['game_dm'].'.html');
        }
    }
    //模板链接指令：通道管理-账号管理
    public function land_list(){
        
        $this->dernout();//判断登录状态
        
        if (!input("id") || input("id") == "") {
            $this->success('1001',null,'id（附加信息：通道ID 参数错误');
        }
        $data = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        $tada = Db::name("pay_jie")->where("pid", $data['id'])->where("id", input("id"))->find();
        
        $tada['name'] = '通道管理-账号管理';//标题
        // 模板变量赋值
        $this->assign('data',$tada);
        
        return $this->fetch();
    }
    //通道管理-账号管理-账号表格数据
    public function land_ajax_list(){
        
        $this->dernout();//判断登录状态
        
        if (!input("id") || input("id") == "") {
            $this->success('1001',null,'id（附加信息：通道ID 参数错误');
        }
        
        $data = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        
        $obj = Db::table('pay_gfg')->where("pid", $data['id'])->where("typec_id", input("id"))->page(input("page"),input("limit"));
        
        if (input("username")){
            $obj = $obj->where("typec_id", input("id"))->where("username",input("username"));
        }
        
        $array = $obj->order("id","desc")->select();
        
        return json(array(
            "code"=>0,
            "msg"=>"获取成功",
            "result"=>
                    array(
                      "data"=>$array,
                      "total"=> $obj->count()
                    ),
        ));
    }
    
    
    //模板链接指令：订单管理
    public function list(){
        
        $this->dernout();//判断登录状态
        $data = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        $data['name'] = '订单管理';//标题
        $data['todayMoney_jintian'] = Db::table('pay_order') ->where("pid", $data["id"])->where("state",2)->whereTime('create_date', 'today')->sum("price");//今日收入
        $data['todayMoney_zuotian'] = Db::table('pay_order') ->where("pid", $data["id"])->where("state",2)->whereTime('create_date', 'yesterday')->sum("price");//昨日收入
        $data['todayMoney_benzho'] = Db::name('pay_order')->where("pid", $data["id"])->where("state",2)->whereTime('create_date', 'week')->sum("price");//本周收入
        $data['todayMoney_benyue'] = Db::name('pay_order')->where("pid", $data["id"])->where("state",2)->whereTime('create_date', 'month')->sum("price");//本月收入
        
        // 模板变量赋值
        $this->assign('data',$data);
        
        return $this->fetch();
    }
    //订单管理-订单表格数据
    public function getOrders(){
        
        $this->dernout();//判断登录状态
        
        $data = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        
        $obj = Db::table('pay_order')->where("pid", $data['id'])->page(input("page"),input("limit"));
        
        if (input("order_id")){
            $obj = $obj->where("order_id",input("order_id"));
        }
        if (input("record")){
            $obj = $obj->where("record",input("record"));
        }
        if (input("mid_type")){
            $obj = $obj->where("mid_type",input("mid_type"));
        }
        if (input("state")){
            $obj = $obj->where("state",input("state"));
        }
        if (input("startDate").input("endDate")){
            $obj = $obj->where("create_date",'>=',strtotime(input("startDate")))->where("create_date",'<=',strtotime(input("endDate")));
        }
        
        $array = $obj->order("id","desc")->select();
        
        return json(array(
            "code"=>0,
            "msg"=>"获取成功",
            "result"=>
                    array(
                      "data"=>$array,
                      "total"=> $obj->count()
                    ),
        ));
    }
    //订单管理-手动补单
    public function reback(){
        
        $this->dernout();//判断登录状态
        
        if (!input("id") || input("id") == "") {
            $this->success('1001',null,'id（附加信息：订单ID 参数错误');
        }
        $data = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        $tada = Db::name("pay_order")->where("pid", $data['id'])->where("id", input("id"))->find();
        if(!$tada){
            $this->success('1002',null,'错误信息：订单ID不存在');
        }
        if($tada['state']==2 and $tada['api_state']==2){
            $this->success('1003',null,'提示信息：该订单ID不需要补单');
        }
        if($tada['sxf']>$data['money']){
            return json($this->getReturn(-1, "商户余额不足，请及时充值"));
        }
        $eer = Db::name("pay_gfg")->where("pid", $tada['pid'])->where("mid",$tada['mid'])->find();
        if($eer){
        $z_pay =  Db::table('pay_order') ->where("pid", $tada['pid'])->where("mid", $eer["mid"])->where("state", 2)->sum("price");//总充值
        $jr_pay =  Db::table('pay_order') ->where("pid", $tada['pid'])->where("mid", $eer["mid"])->where("state", 2)->whereTime('create_date', 'today')->sum("price");//今日充值
        $zr_pay =  Db::table('pay_order') ->where("pid", $tada['pid'])->where("mid", $eer["mid"])->where("state", 2)->whereTime('create_date', 'yesterday')->sum("price");//昨日充值
        Db::name("pay_gfg")->where("pid", $eer["pid"])->where("mid", $eer["mid"])->update(array("z_pay"=>$z_pay,"jr_pay"=>$jr_pay,"zr_pay"=>$zr_pay));
        }
        $hq = huidiao($eer,$tada,$data);//推送异步回调数据
        $money = $data['money']-$tada['sxf'];
        Db::name("pay_user")->where("id", $data['id'])->update(array("money"=>$money));
        if(success($hq)){
            Db::name("pay_order")->where("pid", $data['id'])->where("id", input("id"))->update(array("state"=>2,"api_state"=>2,"pay_date"=>time(),"pay_time"=>time(),"api_budan"=>1));
            return json($this->getReturn(1, "补单成功"));
        }else{
            Db::name("pay_order")->where("pid", $data['id'])->where("id", input("id"))->update(array("state"=>2,"api_state"=>3,"pay_date"=>time(),"pay_time"=>time(),"api_jieguo"=>$hq,"api_budan"=>1));
            return json($this->getReturn(-1, "补单失败"));
        }
        
    }
    
    //模板链接指令：接口信息
    public function jieko(){
        
        $this->dernout();//判断登录状态
        
        $atad = Db::name("pay_sz")->find();
        $data = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        $dhhd = Db::name("pay_gogao")->where("id", ($data['duijei']==1 ? '1':"2"))->find();
        $data['name'] = '接口信息';//标题
        $data['text'] =  $dhhd['text'];//接口文档
        $data['jdfds'] =  ($data['duijei']==1 ? '默认':"易支付");//对接模式
        $data['url'] =  ($atad['ds_rul']=='' ? http_type():$atad['ds_rul']);//支付网关
        // 模板变量赋值
        $this->assign('data',$data);
        
        return $this->fetch();
    }
    //接口信息-重新生成KEY
    public function generatingkey()
    {
        $this->dernout();//判断登录状态
        
        $data = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        
        $key = md5($data['user'].$data['email'].password_hash($data['pass'], PASSWORD_DEFAULT).time());
        
        Db::name("pay_user")->where("user", $data['user'])->update(array("key"=>$key));
        
        return json($this->getReturn(1, "已成功重新生成", $key));
        
    }
    //接口信息-对接模式切换
    public function duijei()
    {
        $this->dernout();//判断登录状态
        
        $data = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        
        if($data['duijei']==1){
            $duijei = '2';
            $eiq = '易支付';
        }else{
            $duijei = '1';
            $eiq = '默认';
        }
        
        Db::name("pay_user")->where("user", $data['user'])->update(array("duijei"=>$duijei));
        
        return json($this->getReturn(1, "切换成功", $eiq));
        
    }
    
    //模板链接指令：余额充值
    public function chozhi(){
        
        $this->dernout();//判断登录状态
        
        if (input()) {
            
            $name = input("name");
            if (!$name || $name == "") {
                return json($this->getReturn(-1, "请输入充值商户"));
            }
            $money = input("money");
            if (!$money || $money == "") {
                return json($this->getReturn(-1, "请输入充值金额"));
            }
            $type = input("type");
            if (!$type || $type == "") {
                return json($this->getReturn(-1, "请选择充值方式"));
            }
            
            $atad = Db::name("pay_sz")->find();
            $hfhd = Db::name("pay_user")->where("type", 2)->find();
            $data = Db::name("pay_user")->where("user", $name)->find();
            if($atad['ds_zaioc']==2){
                return json($this->getReturn(-1, "请联系客服，开启在线余额充值功能"));
            }
            if(!$data){
                return json($this->getReturn(-1, "错误信息：充值商户不存在"));
            }
            
            if($hfhd['duijei']==1){//对接模式
		    $api = array(
			    "pid" => $hfhd['id'],//商户ID
			    "type" => $type,//支付方式
			    "record"=> '余额充值商户：'.$name,//附加参数
			    "money"	=> $money,//付款金额
		        "mid"	=> '',//收款账号MID
			    "refer" =>  http_type().url('user/refer'),//同步回调
			    "notify" => http_type().url('user/notify'),//异步通知
		    );
            $url = laqzf($hfhd,$api,$hfhd['key']);//拉起支付
            }else{
                if($type=='alipay'){
                    $type = 'alipay';
                }elseif($type=='weixin'){
                    $type = 'wxpay';
                }elseif($type=='qq'){
                    $type = 'qqpay';
                }
            $api = array(
			    "pid" => $hfhd['id'],//商户ID
			    "type" => $type,//支付方式
			    "out_trade_no"=> time(),//附加参数
			    "money"	=> $money,//付款金额
			    "name" => '余额充值商户：'.$name,//商品名称
			    "sitename" => '',//网站名称
			    "return_url" =>  http_type().url('user/refer'),//同步回调
			    "notify_url" => http_type().url('user/notify2'),//异步通知
		    );
		    $url = laqzf($hfhd,$api,$hfhd['key']);//拉起支付
            }
            if($atad['ds_zaioc']==1){
                return json($this->getReturn(1, $url));
            }else{
                return json($this->getReturn(2, "调用失败，请联系客服"));
            }
            
        }
        $atad = Db::name("pay_sz")->find();
        $data = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        $data['name'] = '余额充值';//标题
        $data['gogao'] = $atad['tz_yue'];//公告
        $data['web_kefu'] = $atad['web_kefu'];//客服URL
        
        // 模板变量赋值
        $this->assign('data',$data);
        
        return $this->fetch();
    }
    //模板链接指令：余额充值-默认异步回调
    public function notify()
    {
		    $atad = array(
		        "money"	=> input("money"),//付款金额
		        "order" => input("order"),//云端订单号
		        "record"=> input("record"),//附加参数
		        "sign"=> input("sign"),//数据签名
            );
            $data = Db::name("pay_order")->where("order_id", $atad['order'])->find();
            $bqdf = Db::name("pay_user")->where("id", $data['pid'])->find();
            $user = Db::name("pay_user")->where("user", getbstr($atad['record'], '余额充值商户：'))->find();
            $sign = api_huish($atad,$bqdf['key']);
            if($sign===$atad['sign']){
                $rrw = array(
                    "pid" => $data['pid'],//商户PID
                    "user" => $user['user'],//商户账号
                    "money" => $atad['money'],//金额
                    "order" => $atad['order'],//云端订单号
                    "create_date" => time(),//创建时间戳（10位）
                );
                $mnb = Db::name("pay_price")->where("pid", $rrw['pid'])->where("user", $rrw['user'])->where("money", $rrw['money'])->where("order", $rrw['order'])->find();
                if(!$mnb){
                Db::name("pay_price")->insert($rrw);
                }
                return 'success';
            }else{
                return 'fail';
            }
    }
    //模板链接指令：余额充值-易支付异步回调
    public function notify2()
    {
            $atad = input();
            $data = Db::name("pay_order")->where("order_id", $atad['trade_no'])->find();
            $bqdf = Db::name("pay_user")->where("type", 2)->find();
            $user = Db::name("pay_user")->where("user", getbstr($atad['name'], '余额充值商户：'))->find();
            $sign = api_jfjf($atad,$bqdf['key']);
            if($sign===$atad['sign']){
                $rrw = array(
                    "pid" => $data['pid'],//商户PID
                    "user" => $user['user'],//商户账号
                    "money" => $atad['money'],//金额
                    "order" => $atad['trade_no'],//云端订单号
                    "create_date" => time(),//创建时间戳（10位）
                );
                $mnb = Db::name("pay_price")->where("pid", $rrw['pid'])->where("user", $rrw['user'])->where("money", $rrw['money'])->where("order", $rrw['order'])->find();
                if(!$mnb){
                Db::name("pay_price")->insert($rrw);
                }
                return 'success';
            }else{
                return 'fail';
            }
    }
    //模板链接指令：余额充值-同步回调
    public function refer(){
        
        $this->dernout();//判断登录状态
        
        error_reporting(0);  
        $ata = input();
        if(!$ata){
            return $this->fetch('pay/fail');
        }
        if($ata['order']){
            $order = Db::name("pay_order")->where("order_id", $ata['order'])->find();
        }else if($ata['trade_no']){
            $order = Db::name("pay_order")->where("order_id", $ata['trade_no'])->find();
        }
        // 模板变量赋值
        $this->assign('data',$order);
        if($order['state']==2){
            return $this->fetch('pay/success');
        }else{
            return $this->fetch('pay/fail');
        }
        
    }
    //模板链接指令：商户登录
    public function login(){
        
        $data = Db::name("pay_sz")->find();
        $data['name'] = '商户登录';//标题
        // 模板变量赋值
        if(Cookie::has('password')) {
        $this->assign('password',Cookie::get('password'));
        }
        $this->assign('usermember',Cookie::get('usermember'));
        $this->assign('data',$data);
        
        return $this->fetch();
    }
    //商户登录-商户登录
    public function userlogin()
    {
        $user = input("username");
        if (!$user || $user == "") {
            return json($this->getReturn(-1, "请输入登录账号"));
        }
        
        //保存登录账号
        Cookie::forever('usermember',$user);
            
        $pass = input("password");
        if (!$pass || $pass == "") {
            return json($this->getReturn(-1, "请输入登录密码"));
        }
            
        $code = input("code");
        if (!$code || $code == "") {
            return json($this->getReturn(-1, "请输入验证码"));
        }

        $res = Db::name('pay_user')->where('user',$user)->find();
        if ($user != $res["user"]) {
            return json($this->getReturn(-1, "账号或密码错误"));
        }else
        if (!password_verify($pass, $res["pass"])) {
            return json($this->getReturn(-1, "账号或密码错误"));
        }
        if(!captcha_check($code)){
            return json($this->getReturn(-1, "验证码错误"));
        }
        //是否记住密码input("type")
        if(!empty(input("remember")) and input("remember") == 1) {
            //检查当前有没有记住的密码
            if(Cookie::has('password')) {
                    Cookie::delete('password');
            }
            //保存新的
            Cookie::forever('password',$pass);
        } else {
            //未选择记住账号，或属于取消操作
            if(Cookie::has('password')) {
                Cookie::delete('password');
            }
        }
        
        $atad = Db::name("pay_user")->where("user", $user)->find();
        if($atad['active']==1 and $atad['type']!=2){
            return json($this->getReturn(-1, "您登录的账号已被禁用，请联系客服咨询原因"));
        }
        
        if($atad['type']==2){
            Cookie::set(md5(date("m-Y")),$res['user'],['prefix'=>md5(date("d-m-Y")),'expire'=>0]);
            $data = array(
                "user" => $res['user'],//后台账号
                "ip" => real_ip(),//登录IP
            );
            Db::name("pay_sz")->where("id",1)->update($data);
        }
        
        Cookie::set(md5(date("Y-m")),$res['user'],['prefix'=>md5(date("Y-m-d")),'expire'=>0]);
        
        Db::name("pay_user")->where("user",Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->update(array("scsj"=>time(),"ip" => real_ip()));

        return json($this->getReturn(1, "登录成功"));
    }
    //模板链接指令：商户注册
    public function reg(){
        
        $data['name'] = '商户注册';//标题
        // 模板变量赋值
        $this->assign('data',$data);
        
        return $this->fetch();
    }
    //商户注册-商户注册
    public function userreg()
    {
        $fa = Db::name('pay_sz')->find();
        if ($fa['ds_user'] == "2") {
            return json($this->getReturn(2, $fa['ds_txet']));
        }
        $user = input("username");
        if (!$user || $user == "") {
            return json($this->getReturn(-1, "请输入登录账号"));
        }
        $pass = input("password");
        if (!$pass || $pass == "") {
            return json($this->getReturn(-1, "请输入登录密码"));
        }
        $pass2 = input("password2");
        if (!$pass2 || $pass2 == "") {
            return json($this->getReturn(-1, "请再次输入登录密码"));
        }
        if (!$pass===$pass2) {
            return json($this->getReturn(-1, "输入登录密码不一致"));
        }
        $email = input("email");
        if (!$email || $email == "") {
            return json($this->getReturn(-1, "请输入邮箱账号"));
        }
        if (!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/",$email)) {
            return json($this->getReturn(-1, "您输入的电子邮件地址不合法"));
        }
        $res = Db::name('pay_user')->where('user',$user)->find();
        if ($res['user']) {
            return json($this->getReturn(-1, "输入账号已被注册，请重新输入登录账号"));
        }else{
        $data = array(
            "key" => md5($user.$email.password_hash($pass, PASSWORD_DEFAULT).time()),
            "user" => $user,
            "pass" => password_hash($pass, PASSWORD_DEFAULT),
            "email" => $email,
            "money" => $fa['ds_money'],
            "fee" => $fa['ds_fee'],

        );
        Db::table('pay_user')->insert($data);
            return json($this->getReturn(1, "商户注册成功"));
        }
    }
    //模板链接指令：重置密码
    public function forget(){
        
        $data['name'] = '重置密码';//标题
        // 模板变量赋值
        $this->assign('data',$data);
        
        return $this->fetch();
    }
    //重置密码-修改商户密码
    public function userforget()
    {
        $username = input("username");
        if (!$username || $username == "") {
            return json($this->getReturn(-1, "请输入登录账号"));
        }
        $res = Db::name('pay_user')->where('user',$username)->find();
        if (!$res['user']) {
            return json($this->getReturn(-1, "输入登录账号不存在，请重新输入登录账号"));
        }
        $pass = input("password");
        if (!$pass || $pass == "") {
            return json($this->getReturn(-1, "请输入修改密码"));
        }
        $pass2 = input("password2");
        if (!$pass2 || $pass2 == "") {
            return json($this->getReturn(-1, "请再次输入修改密码"));
        }
        if (!$pass===$pass2) {
            return json($this->getReturn(-1, "输入修改密码不一致"));
        }
        $code = input("code");
        if (!$code || $code == "") {
            return json($this->getReturn(-1, "请输入验证码"));
        }
        $cache = tohc("sendEmailVer");
        if ($cache->get($username)==$code) {
            Db::name("pay_user")->where("user", $username)->update(array("pass"=>password_hash($pass, PASSWORD_DEFAULT)));
            return json($this->getReturn(1, "修改密码成功"));
        }else{
            return json($this->getReturn(-1, "输入验证码错误"));
        }  
    }
    
    //重置密码-获取验证码
    public function sendEmailVer()
    {
        $username = input("username");
        if (!$username || $username == "") {
            return json($this->getReturn(-1, "请输入登录账号"));
        }
        $code = input("code");
        if (!$code || $code == "") {
            return json($this->getReturn(-1, "请输入验证码"));
        }
        if(!captcha_check($code)){
            return json($this->getReturn(-1, "验证码错误"));
        }
        $res = Db::name('pay_user')->where('user',$username)->find();
        if (!$res['user']) {
            return json($this->getReturn(-1, "输入登录账号不存在，请重新输入登录账号"));
        }
        if(Cookie::has('yanzhengma')){
            return json($this->getReturn(-1, '请求验证码频率过于频繁，请60秒后操作'));
        }else{
            $ds = Db::name("pay_sz")->find();
            $code = str_rand(5);//获取的验证码
            $sub= $ds['web_name'].'-重置密码-验证码通知';
            $msg = "【重置密码】您正在使用".$ds['web_name']."重置密码，验证码：" .$code. "，60秒内有效，如有疑虑请详询（客服）";
            if(fmail($res['email'], $sub, $msg)==true){
                $cache = tohc("sendEmailVer");
                $cache->set($username,$code,60);
                return json($this->getReturn(1, "验证码发送到您的邮件里，请注意查收"));
            }else{
                return json($this->getReturn(-1, "对不起，邮件发送失败！如有疑虑请详询（客服）"));
            }
        } 
    }
    
    //云端接口
    public function api()
    {
        $this->dernout();//判断登录状态
        $cache = tohc('Heart');
        error_reporting(0);
        $api = input();//判断：GET和POST
        $post = array(
            'game_dm' => $api['game_dm'],//通道标识
            'type' => $api['type'],//传出类型:支付类型:exec||监控类型:cehsald
            'post' => array(//传出数据
                        'qrsig' => $api['post']['qrsig'],//qrsig
                        'loginid' => $api['post']['loginid'],//loginid
                        'zhanghao' => $api['post']['zhanghao'],//应用的APPID
                        'ck' => $api['post']['ck'],//账号Cookie
                        'type' => $api['post']['type'],//支付类型
                        'money' => $api['post']['money'],//支付金额
                        'orderid' => $api['post']['orderid'],//支付金额
                    )
        );
        if($cache->get('pcyjk')>=date('Y-m-d H:i:s',time())){
            $ret = get_curl($cache->get('cookie_ip')."/?".http_build_query($post));
        }else{
            $ret = get_curl($cache->get('ds_todaorul')."/?".http_build_query($post));
        }
        echo $ret;
    }
    
    //二维码解析
    public function upload()
    {
        $this->dernout();//判断登录状态
        
    // 获取表单上传文件 例如上传了001.jpg
    $file = request()->file('file');
    // 移动到框架应用根目录/public/static/user/assets/erweima/ 目录下
    $info = $file->validate(['ext'=>'jpg,png,gif'])->move( '../public/static/user/assets/erweima/',true,false);
    $dsa = "../static/user/assets/erweima/20210714/";
    if($info){
        $ret = curls('https://cli.im/apis/up/deqrimg','img='.http_type().'/static/user/assets/erweima/'.$info->getSaveName());
        $json = json_decode($ret,TRUE);
        @unlink("../public/static/user/assets/erweima/".$info->getSaveName());//删除目录图片
        if($json['info'] == '无法扫描出该图片的内容！' || $json['info'] == '禁止上传该类型文件'){
            return json($this->getReturn(-1, '这似乎不是一个二维码或者服务器网络错误！'));
        }else{
            return json($this->getReturn(1, $json["info"]["data"][0]));
        }
    }else{
        return json($this->getReturn(-1, '上传失败'));
    }
    
    }
    
    //最新订单实时提醒
    public function dsadsa()
    {
        $this->dernout();//判断登录状态
        $roo = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        $todr1 = Db::name("pay_order")//等待支付
            ->where("pid", $roo["id"])
            ->where("state",1)
            ->whereTime('create_date', '<=', time())
            ->whereTime('create_date', '>=', time()-1)
            ->find();
        $todr2 = Db::name("pay_order")//补单成功
            ->where("pid", $roo["id"])
            ->where("state",2)
            ->where("api_budan",1)
            ->whereTime('pay_time', '<=', time())
            ->whereTime('pay_time', '>=', time()-1)
            ->find();
        $todr3 = Db::name("pay_order")//支付完成但通知失败
            ->where("pid", $roo["id"])
            ->where("state",2)
            ->where("api_state",3)
            ->whereTime('pay_date', '<=', time())
            ->whereTime('pay_date', '>=', time()-1)
            ->find();    
        $todr4 = Db::name("pay_order")//支付成功
            ->where("pid", $roo["id"])
            ->where("state",2)
            ->whereTime('pay_date', '<=', time())
            ->whereTime('pay_date', '>=', time()-1)
            ->find();     
        if($todr1){
            return json($this->getReturn(1, "等待支付"));
        }else if($todr2){
            return json($this->getReturn(2, "补单成功"));
        }else if($todr3){
            return json($this->getReturn(3, "支付完成但通知失败"));
        }else if($todr4){
            return json($this->getReturn(4, "支付成功"));
        }else{
            return json($this->getReturn(0, "ok"));
        }
    }
    
    public function money()//取余额
    {
        $this->dernout();//判断登录状态
        
        $id = input("id");
        if (!$id || $id == "") {
            return json($this->getReturn(-1, "获取余额失败"));
        }
        $res = Db::name('pay_user')->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        $ree = Db::name("pay_gfg")->where("pid", $res['id'])->where("id",$id)->find();
        $ret = Db::name("pay_jie")->where("pid", $res['id'])->where("id",$ree['typec_id'])->find();
        $cls = app("\\app\wenjian\\".'Pay_Money_Api');
        $json = $cls->Get_pay_money($ret['game_dm'],$ree['ck']);
        if($json['code']==1){
            return json($this->getReturn(1, $json['money']));
        }else{
            return json($this->getReturn(-1, $json['money']));
        }
    }
    
    //模板链接指令：支付监控
    public function jiankong(){
        
        $this->dernout();//判断登录状态
        
        $data = Db::name("pay_user")->where("user", Cookie::get(md5(date("Y-m")),md5(date("Y-m-d"))))->find();
        $cache = tohc('Heart');
        $data['name'] = '支付监控';//标题
        if($cache->get('pcyjk')>=date('Y-m-d H:i:s',time())){//PC云监控
            $ip = checkServerSatatus($cache->get('ds_todaorul'));
            if($ip['code']==0){
                $data['pcyjk1'] =  '无法读取(外网)';//服务器地址
                $data['pcyjk2'] =  '无法读取(外网)';//服务器速度
                $data['pcyjk3'] =  $ip['msg'];//服务器状态
            }else{
                $data['pcyjk1'] =  $ip['Country'];//服务器地址
                $data['pcyjk2'] =  'ms:'.$ip['Ping'];//服务器速度
                $data['pcyjk3'] =  $ip['msg'];//服务器状态
            }
        }else{
            if($cache->get('cehsald')>=date('Y-m-d H:i:s',time())){//备用云监控
                $ip = checkServerSatatus($cache->get('ds_todaorul'));
                if($ip['code']==0){
                    $data['pcyjk1'] =  '无法读取';//服务器地址
                    $data['pcyjk2'] =  '无法读取';//服务器速度
                    $data['pcyjk3'] =  $ip['msg'];//服务器状态
                }else{
                    $data['pcyjk1'] =  $ip['Country'];//服务器地址
                    $data['pcyjk2'] =  'ms:'.$ip['Ping'];//服务器速度
                    $data['pcyjk3'] =  $ip['msg'];//服务器状态
                }
            }else{
                $data['pcyjk1'] =  '无法读取';//服务器地址
                $data['pcyjk2'] =  '无法读取';//服务器速度
                $data['pcyjk3'] =  '不在线[异常]';//服务器状态
            }
        }
        if($cache->get('appjkd')>=date('Y-m-d H:i:s',time())){//监控端
            $data['appjkd'] =  '在线[正常]';//监控状态
        }else{
            $data['appjkd'] =  '不在线[异常]';//监控状态
        }
        if($cache->get('cehsald')>=date('Y-m-d H:i:s',time())){//通道监控（计划任务）
            $data['cehsald'] =  '在线[正常]';//监控状态
        }else{
            $data['cehsald'] =  '不在线[异常]';//监控状态
        }
        
        // 模板变量赋值
        $this->assign('data',$data);
        
        return $this->fetch();
    }
    
}
